package com.video.web.controller.video;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.video.common.annotation.Log;
import com.video.common.core.controller.BaseController;
import com.video.common.core.domain.AjaxResult;
import com.video.common.enums.BusinessType;
import com.video.video.domain.DSystemSettings;
import com.video.video.service.IDSystemSettingsService;
import com.video.common.utils.poi.ExcelUtil;
import com.video.common.core.page.TableDataInfo;

/**
 * 系统设置Controller
 *
 * @author ruoyi
 * @date 2022-09-27
 */
@RestController
@RequestMapping("/video/DSystemSettings")
public class DSystemSettingsController extends BaseController
{
    @Autowired
    private IDSystemSettingsService dSystemSettingsService;

    /**
     * 查询系统设置列表
     */
    @PreAuthorize("@ss.hasPermi('video:DSystemSettings:list')")
    @GetMapping("/list")
    public TableDataInfo list(DSystemSettings dSystemSettings)
    {
        startPage();
        List<DSystemSettings> list = dSystemSettingsService.selectDSystemSettingsList(dSystemSettings);
        return getDataTable(list);
    }

    /**
     * 导出系统设置列表
     */
    @PreAuthorize("@ss.hasPermi('video:DSystemSettings:export')")
    @Log(title = "系统设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DSystemSettings dSystemSettings)
    {
        List<DSystemSettings> list = dSystemSettingsService.selectDSystemSettingsList(dSystemSettings);
        ExcelUtil<DSystemSettings> util = new ExcelUtil<DSystemSettings>(DSystemSettings.class);
        util.exportExcel(response, list, "系统设置数据");
    }

    /**
     * 获取系统设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('video:DSystemSettings:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(dSystemSettingsService.selectDSystemSettingsById(id));
    }

    /**
     * 新增系统设置
     */
    @PreAuthorize("@ss.hasPermi('video:DSystemSettings:add')")
    @Log(title = "系统设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DSystemSettings dSystemSettings)
    {
        return toAjax(dSystemSettingsService.insertDSystemSettings(dSystemSettings));
    }

    /**
     * 修改系统设置
     */
    @PreAuthorize("@ss.hasPermi('video:DSystemSettings:edit')")
    @Log(title = "系统设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DSystemSettings dSystemSettings)
    {
        return toAjax(dSystemSettingsService.updateDSystemSettings(dSystemSettings));
    }

    /**
     * 删除系统设置
     */
    @PreAuthorize("@ss.hasPermi('video:DSystemSettings:remove')")
    @Log(title = "系统设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dSystemSettingsService.deleteDSystemSettingsByIds(ids));
    }
}
